package com.cn.study008;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author lw
 * @ClassName Test8007.java
 * @Description
 * @createTime 2023年05月14日 18:03:00
 */
public class Test8007 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] c=new char[]{'a','c','u','b','e','p','f','z'};
        System.out.print("原字符序列：");
        for (char str:c) {
            System.out.print(str+" ");
        }
        Arrays.sort(c);
        System.out.print("\n升序排序后：");
        for (char str:c) {
            System.out.print(str+" ");
        }
        char str='m';
        System.out.print("\n待插入字符是："+str);
        int n=0;
        for (int i = 0; i < c.length; i++) {
            if (str<c[i]){
                n=i;
                break;
            }
        }
        System.out.print("\n插入成绩的下标是："+n);
        for (int i = c.length-1; i>n; i--) {
            c[i]=c[i-1];
        }
        c[n]=str;
        System.out.print("\n插入后的字符序列是：");
        for (int i = 0; i < c.length; i++) {
            System.out.print(c[i]+" ");
        }
    }
}
